import request from '@/utils/request';

/**
 * 分页查询海运散货运费
 */
export async function pageOceanBulkCargoFee(params) {
  const res = await request.get('/ocean/oceanBulkCargoFee/page', { params });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 查询海运散货运费列表
 */
export async function listOceanBulkCargoFee(params) {
  const res = await request.get('/ocean/oceanBulkCargoFee', { params });
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 根据id查询海运散货运费
 */
export async function getOceanBulkCargoFee(id) {
  const res = await request.get('/ocean/oceanBulkCargoFee/' + id);
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 添加海运散货运费
 */
export async function addOceanBulkCargoFee(data) {
  const res = await request.post('/ocean/oceanBulkCargoFee', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 修改海运散货运费
 */
export async function updateOceanBulkCargoFee(data) {
  const res = await request.put('/ocean/oceanBulkCargoFee', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 删除海运散货运费
 */
export async function removeOceanBulkCargoFee(id) {
  const res = await request.delete('/ocean/oceanBulkCargoFee/' + id);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
